<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.point.business.database.model.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Administrator console</title>
<link rel="icon" type="img/ico" href="images/icons/favicon.ico">
<jsp:include page="../loadResources.jsp" />
</head>
<script>
var contextPath = '<%=request.getContextPath()%>'; 
$( document ).ready(function() {
	 $('#allUsersCombo').combobox({
			url: contextPath + '/servlet/AllUsersServlet',  
			panelHeight:'auto', 
	        valueField:'id',
	        textField:'fullName',
	        onSelect:function(record){
	                $('#statisticGrid').datagrid({
	                   url: contextPath + "/servlet/UsersHistory?id="+record.id ,
		    	       onClickRow:function(index,row){
		    	        	$('#dlgStatistic').dialog('open').dialog('setTitle', 'Детални инфромации');
		    	    		$('#searchQuery').text(row.searchQuery);
		    	    		$('#searchDate').text(row.searchDate);
		    	    		$('#results').text(row.results);
		    	    		$('#searchObject').text(row.searchObject);
		    	    		$.extend($.fn.dialog.methods, {
						        mymove: function(jq, newposition){
						        	return jq.each(function(){
						        	$(this).dialog('move', newposition);
						        	});
						        }
						    });
						    $('#dlgStatistic').dialog('mymove', {
						        top: 250
						    });
		    	        }
	                });
	                $('#notificationStatisticGrid').datagrid({
		                   url: contextPath + "/servlet/AllActiveNotificationByUserServlet?userId="+record.id + "&type="
		                });
	        }
	    });
	        
	});
$(document).keypress(function(e) { 
    if (e.keyCode == 27) { 
        $('#dlgStatistic').dialog('close');
    } 
});
</script>
<body id="page1">
	<div class="bg">
		<div class="main">
			<header> <jsp:include page="../header.jsp" />
			<div class="row-2-1">
				<nav>
				<ul class="tabMenu">
					<li><a href="admin.jsp">Корисници</a></li>
					<li><a href="upload.jsp">Прикачи датотека</a></li>
					<li><a class="active" href="statistics.jsp">Статистики</a></li>
					<!-- <li><a href="products.html">Our Products</a></li>
						<li class="last-item"><a href="contacts.html">Contact Us</a></li> -->
				</ul>
				</nav>
			</div>
			</header>
			<section id="content">
			<div class="padding">
				<div class="box-bg">
					<div class="wrapper">
						<div class="pull-left statistic-input-wrapper">
							<span class="pull-left color-4 input-label">Корисник:</span>
							<select id="allUsersCombo" class="easyui-combobox" name="state" style="width:200px;">
							</select>
						</div>
						<div class="pull-left">
							<table id="statisticGrid" class="easyui-datagrid"
								style="width: 994px; height: 400px"
								title="Статистика" rownumbers="true"
								nowrap="false" autoRowHeight="true" fitColumns="true" singleSelect="true">
								<thead>
									<tr>
										<th field="searchQuery" width="200">Пребарувал</th>
										<th field="searchDate" width="80" align="right">Датум</th>
										<th field="results" width="30" align="right">Резултат</th>
										<th field="searchObject" width="50" align="right">Пребарувано во</th>
									</tr>
								</thead>
							</table>
							<br>
							<table id="notificationStatisticGrid" class="easyui-datagrid"
								style="width: 994px; height: 400px"
								title="Активни нотификации" rownumbers="true"
								fitColumns="true" nowrap="false" autoRowHeight="true">
								<thead>
									<tr>
										<th field="notification" width="100" sortable="true" align="left">Нотификација</th>
										<th field="active" width="40" align="left">Статус</th>
										<th field="searchDate" sortable="true" width="40" align="left">Датум</th>
									</tr>
								</thead>
							</table>
							<div id="dlgStatistic" class="easyui-dialog" modal="true"
							style="width: 400px; height: 386px; padding: 10px 20px"
							closed="true" buttons="#dlg-buttons">
							<div class="ftitle margin-bottom-15 result-content-header">Детални информации</div>
								<form id="fmStatistic" method="post">
									<div class="margin-bottom-15">
										<label class="input-dialog-admin">Пребарувал:</label> <span
											id="searchQuery" class="easyui-validatebox"></span>
									</div>
									<div class="margin-bottom-15">
										<label class="input-dialog-admin">Датум:</label> <span
											id="searchDate" class="easyui-validatebox"></span>
									</div>
									<div class="margin-bottom-15">
										<label class="input-dialog-admin">Резултат:</label> <span 
											id="results" class="easyui-validatebox" ></span>
									</div>
									<div class="margin-bottom-15">
										<label class="input-dialog-admin">Пребарувано во:</label> <span
											id="searchObject" class="easyui-validatebox"></span>
									</div>
								</form>
							</div>
                                                  	<div id="dlg-buttons">
                                                         <a href="#"
                                                                  class="easyui-linkbutton" iconCls="icon-cancel"
								onclick="javascript:$('#dlgStatistic').dialog('close')">Затвори</a>
							</div>
						</div>
					</div>
				</div>
			</div>
			</section>
			<footer> <jsp:include page="../footer.jsp" /> </footer>
		</div>
	</div>
</body>
</body>
</html>